package com.optitronics.controllers;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.optitronics.beans.Administrator;
import com.optitronics.util.OptitronicsUtils;

@Controller
public class OptitronicsUtilController {

	@RequestMapping("/changePersonalData")
	public String changePersonalData() {

		String link = "";
		if (OptitronicsUtils.isUserReseller()) {
			link = "redirect:/resellers/-1/edit";
		} else if (OptitronicsUtils.isUserAdmin()) {
			Administrator admin = Administrator.findByUsername(OptitronicsUtils.getActiveUser());
			link = "redirect:administrators/" + admin.getId() + "/edit";
		}

		return link;

	}

}
